<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\DbConnection\Model\Model;
/**
 * @property int $id
 * @property int $group_id
 * @property int $user_id
 */
class GroupMember extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'group_member';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'int', 'group_id' => 'integer', 'user_id' => 'integer'];



    protected $hidden  = [
        'groupTableInfo'
    ];

    protected $appends = [
        'group_info'
    ];


    /**
     * group_info
     */
    public function getGroupInfoAttribute()
    {
        return $this->groupTableInfo;
    }

    public function groupTableInfo()
    {
        return $this->belongsTo(GroupTable::class, 'group_id', 'id')->select('group_table.id','group_table.groupname','group_table.avatar');
    }
}
